package com.swing.gui.pages;

import base.JPanelBase;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Yuang, Gongming
 * @date 2022-01-18 17:18
 */
public class Home extends JPanel implements JPanelBase {
    private static Home home;

    private Home(){}

    public static Home init(){
        if(home == null){
            synchronized (Home.class){
                if(home == null){
                    home = new Home();
//                    jPanel.add(Head.init(), "Head");
//                    jPanel.add(Feet.init(), "Feet");
                    style();
                }
            }
        }
        return home;
    }

    private static void style(){
        home.setBackground(Color.LIGHT_GRAY);

        JLabel time = new JLabel("时间", JLabel.RIGHT);
        time.setSize(200,20);
        time.setBackground(Color.BLUE);
        new Timer(1000, new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                time.setText(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
                time.setFont(new Font(null, Font.BOLD, 20));
            }
        }).start();
        home.add(time, BorderLayout.NORTH);
    }


    @Override
    public void css() {

    }

    @Override
    public void planning() {

    }

    @Override
    public void event() {

    }
}
